{include file='head'/}
<title>修改个人信息</title>
<body>
<div class="mainBox">
    <div class="main-container">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md3">
                <form id="app-form" class="layui-form layuimini-form" action="{:__url('index/edit_info')}"
                      method="post">
                    <div class="layui-form-item hui-home-show" style="margin-top:20px">
                        <div class="avatar hui-upload-avatar">
                            <i></i>
                            <input type="hidden" value="{$data.avatar}" name="avatar"
                                   class="layui-input layui-input-disabled"
                                   id="avatar">
                            <img src="{$data.avatar}">
                            <div class="cover">点击编辑</div>
                        </div>
                        <div class="username">{$data.username}</div>
                        <div class="email">{$data.email}</div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label required">登录账户</label>
                        <div class="layui-input-block">
                            <input type="text" name="username" class="layui-input readonly_bg" readonly=""
                                   value="{$data.username}">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label required">昵称</label>
                        <div class="layui-input-block">
                            <input type="text" name="nickname" class="layui-input" value="{$data.nickname}"
                                   lay-verify="required">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">用户email</label>
                        <div class="layui-input-block">
                            <input type="text" name="email" class="layui-input" lay-reqtext="请输入email"
                                   placeholder="请输入email" value="{$data.email}" lay-verify="email">
                            <tip>填写邮箱。</tip>
                        </div>
                    </div>

                    <div class="hr-line"></div>
                    <div class="layui-form-item text-center">
                        <button class="layui-btn layui-btn-sm" lay-filter="doSub" lay-submit>立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                    </div>
                </form>
            </div>
            <div class="layui-col-md9">
                <div class="layui-tab layui-tab-brief" lay-filter="tab">
                    <ul class="layui-tab-title">
                        <li class="layui-this">登录日志</li>
                        <li class="">操作日志</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <table id="login_log" lay-filter="login_log"></table>
                        </div>
                        <div class="layui-tab-item">
                            <table id="system_log" lay-filter="system_log"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/html" id="statusTpl">
            {{#  if(d.status =='1'){ }}
            <span class="layui-badge layui-bg-green">登录成功</span>
            {{#  } else { }}
            <span class="layui-badge layui-bg-danger">登录失败</span>
            {{#  } }}
        </script>
    </div>
</div>

{include file='footer'/}
<script>
  layui.use(['upload', 'jquery', 'table'], function () {
    var layuiUpload = layui.upload, $ = layui.jquery;
    var table = layui.table;
    layuiUpload.render({
      elem: '.hui-upload-avatar'
      , url: GV.upload_url
      , before: function (obj) {
        //console.log(obj);
        obj.preview(function (index, file, result) {

        });
      }
      , done: function (res) {
        layer.msg('上传成功');
        $('.hui-upload-avatar img').attr('src', res.data.url);
        $('#avatar').val(res.data.url);
        //修改头像
        $.post("{:__url('index/edit_info')}", {avatar: res.data.url}, function () {
          //console.log(res);
        })
      }
    });

    table.render({
      elem: '#login_log'
      , method: 'get'
      , url: "{:__url('index/login_log')}"
      , parseData: function (res) {
        return {
          "code": res.code_lay,
          "msg": res.msg,
          "count": res.count,
          "data": res.data
        };
      }
      , cellMinWidth: 100
      , cols: [[
        {field: 'user_name', title: '管理员名称', width: 100}
        , {field: 'ip_address', title: 'ip地址'}
        , {field: 'address', title: '地区'}
        , {field: 'isp', title: '网络'}
        , {field: 'status', title: '登录成/失败', width: 100, align: 'center',templet: '#statusTpl'}
        , {field: 'create_time', title: '登录时间', width: 170}
      ]]
      , id: 'testReload'
      , page: true
      , limit: 10
    });

    table.render({
      elem: '#system_log'
      , method: 'get'
      , url: "{:__url('index/system_log')}"
      , parseData: function (res) {
        return {
          "code": res.code_lay,
          "msg": res.msg,
          "count": res.count,
          "data": res.data
        };
      }
      , cellMinWidth: 100
      , cols: [[
        {field: 'url', title: '操作地址'}
        , {field: 'content', title: '操作内容'}
        , {field: 'ip', title: 'ip地址', width: 120}
        , {field: 'create_time', title: '操作时间', width: 170}
      ]]
      , id: 'systemLogReload'
      , page: true
      , limit: 10
    });

  });
</script>
</body>
</html>
